package com.jobs.producer0.controller;

import com.jobs.common.factory.RabbitMqUtils;
import com.rabbitmq.client.Channel;

import java.util.Scanner;

public class Task01 {
    public static final String QUEUE_NAME = "hello";

    public static void main(String[] args) throws Exception {

        Channel channel = RabbitMqUtils.getChannel();

        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            //hasNext，有下一个，就发送
            String message = scanner.next();
            channel.basicPublish("", QUEUE_NAME, null, message.getBytes());
            //生产者发送消息，理解各参数意思
            System.out.println("消息发送完成：" + message);
        }

    }
}
